<template>
  <view class="exam-plan-container">
    <text class="title">培训记录</text>
    <view class="exam-list">
      <view class="exam-item" v-for="exam in examList" :key="exam.id">
        <view class="exam-header">
          <text class="exam-name">培训科目：{{ exam.name }}</text>
          <text class="exam-nickname">创建人: {{ exam.nickName }}</text>
        </view>
		<text class="workName">培训人: {{ exam.workName }}</text><br/>
		<text class="exam-score">得分: {{ exam.score }}</text><br/>
        <text class="exam-description">培训时间: {{ exam.examDate }}</text><br/>
        <text class="exam-evaluation">评价: {{ exam.evaluation || '无' }}</text>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      examList: []
    }
  },
  onLoad() {
    this.fetchExamPlanData();
  },
  methods: {
    fetchExamPlanData() {
      // 假设使用 uni.request 发送请求
      uni.request({
        url: 'http://127.0.0.1:1004/mesSafetyScore/findAllSafetyScore', // 替换为实际的 API 地址
        method: 'GET',
        success: (res) => {
          if (res.data.code === 200) {
            this.examList = res.data.data;
          } else {
            console.error('获取培训计划失败:', res.data.msg);
          }
        },
        fail: (err) => {
          console.error('请求失败:', err);
        }
      });
    }
  }
}
</script>

<style lang="scss">
.exam-plan-container {
  padding: 20rpx;
  background-color: #f8f8f8;
  border-radius: 20rpx;
  margin-bottom: 20rpx;
  box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
}

.title {
  font-size: 36rpx;
  font-weight: bold;
  text-align: center;
  margin-bottom: 30rpx;
  color: #333;
}

.exam-list {
  display: flex;
  flex-direction: column;
}

.exam-item {
  padding: 30rpx;
  background-color: #fff;
  border-radius: 20rpx;
  margin-bottom: 20rpx;
  box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.exam-item:hover {
  transform: translateY(-5rpx);
  box-shadow: 0 8rpx 20rpx rgba(0, 0, 0, 0.2);
}

.exam-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20rpx;
}

.exam-name {
  font-size: 30rpx;
  font-weight: bold;
  color: #333;
}

.exam-nickname {
  font-size: 24rpx;
  color: #999;
}

.exam-description {
  font-size: 28rpx;
  color: #666;
  margin-bottom: 15rpx;
}

.exam-score {
  font-size: 28rpx;
  color: #333;
  margin-bottom: 15rpx;
}

.exam-evaluation {
  font-size: 24rpx;
  color: #999;
}
</style>
